# -*- coding: utf-8 -*-
"""
Created on Tue Oct  8 07:46:15 2019

@author: ASUS
"""
print('---------------------------------')
s = '中国陕西咸阳'
print(len(s))
s='XIDJY'
print(len(s))
s = '中国陕西咸阳XIDJY'
print(len(s))
姓名 = '张三'
年龄 = 40
print(姓名)
print(年龄)
print('-------------字符串--------------------')
print('---短字符串的驻留机制---')
a = '1234'
b = '1234'
print(id(a)==id(b))
a = '1234' * 50000
b = '1234' * 50000
print(id(a)==id(b))
print('---字符串格式化---')
x = 1235
so = "%o"%x
print(so)
sh = "%x"%x
print(sh)
se = "%e"%x
print(se)
print(chr(ord("3")+1))
print("%s"%65)
print("%s"%65333)
print('%d,%c'%(65,65))
#print("%d"%"555")
print(int('555'))
print('%s'%[1,2,3])
print(str((1,2,3)))
print(str([1,2,3]))
print('---字序列解包格式化字符串---')
print('The number {0:,} in hex is:{0:#x},the number {1} in oct is {1:#o}'.format(5555,35))
print("The number {1:,} in hex is :{1:#x},the number {0} in oct is{0:#o}".format(5555,35))
print("my name is {name},my age is {age},and my qq is {qq}".format(name="DongYiXin",qq="227043834",age=20))
position = (5,8,13)
print("X:{0[0]};Y:{0[1]};Z:{0[2]}".format(position))
weather = [("Monday","rain"),("Tuesday","sunny"),("Wednesday","sunny"),("Thursday","rain"),("Friday","Cloudy")]
formatter = "Weather of '{0[0]}' is '{0[1]}'".format
for item in map(formatter,weather):
    print(item)
for item in weather:
    print(formatter(item))
print(formatter(("Monday","cloudy")))
print('---字符串常用方法---')
print('--find(),rfind(),index(),rindex(),count()--')
s = "apple,peach,banana,peach,pear"
print(s.find("peach"))
print(s.find("peach",7))
print(s.find("peach",7,20))#在指定范围中查找
print(s.rfind('p'))
print(s.index('pe'))
print(s.index('pear'))
#print(s.index('ppp'))#指定子字符串不存在时抛出异常
print(s.count('p'))#统计子字符串出现次数
print(s.count('pp'))
print(s.count('ppp'))
print('--split(),rsplit(),partition(),rpartition()--')
s = "apple,peach,banana,pear"
li = s.split(",")
print(li)
si = s.partition(',')
print(si)
print(s.rpartition(','))
print(s.rpartition('banana'))
s = "2014-10-31"
t = s.split("-")
print(t)
print(list(map(int,t)))
s = '\n\nhello\t\t world \n\n\n My name is Dong '
print(s)
print(s.split())
print(s.split(None,2))
print(s.rsplit(None,2))
print(s.split(None,6))
li = ["apple","peach","banana","pear"]
sep = ","
s = sep.join(li)
print(s)















































    
    
    
    
    
    
    
    
    
    
    
    
    
    
    